<?php
namespace Core;
class Once {
    static $data = [];
    static $APP_PATH;
    static $APP_PARAM;
    /**
     * @var \swoole_http_request
     */
    static $REQUEST;
    /**
     * @var \swoole_http_response
     */
    static $RESPONSE;

    static $Controller;
    static function set($name,$value) {
        self::$data[$name] = $value;
    }
    static function get($name,$value=null) {
        if(isset(self::$data[$name])) {
            return self::$data[$name];
        }else {
            if($value !== null) {
                self::$data[$name] = $value;
            }
            return $value;
        }
    }

    static function close() {
        self::$data = [];
        self::$RESPONSE = null;
        self::$REQUEST = null;
        self::$Controller = null;
        self::$APP_PATH = '';
        self::$APP_PARAM = '';
    }
}